package com.russell.pms.dao.hibernate;

import java.util.List;

import com.russell.pms.dao.PropertyDao;
import com.russell.pms.model.Property;

/**
 * 
 * @author <a href="mailto:fvinluan@gmail.com">Francis Vinluan</a>
 * 
 * @version $Revision: 1.0 $
 */
public class PropertyHibernate extends BaseDaoHibernate implements PropertyDao {

	/**
	 * Gets a list of all vendor.
	 * 
	 * 
	 * @return List populated list of vendor * @see
	 *         com.princess.etrak.dao.PropertyDao#getPropertyList() * @see
	 *         com.princess.etrak.dao.PropertyDao#getPropertyList() * @see
	 *         com.princess.etrak.dao.PropertyDao#getPropertyList() * @see
	 *         com.princess.etrak.dao.PropertyDao#getPropertyList()
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Property> getProperties() {
		if (logger.isDebugEnabled()) {
			logger.debug("getting all vendor begins");
		}
		List<Property> cList = getCurrentSession().createQuery("FROM Property")
				.list();
		if (cList == null || cList.size() < 1)
			return null;
		if (logger.isDebugEnabled()) {
			logger.debug("getting all vendor ends: ");
		}
		return cList;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.princess.etrak.dao.PropertyDao#getProperty(java.lang.Short)
	 */
	/**
	 * Method getProperty.
	 * 
	 * @param id
	 *            Long
	 * 
	 * @return Property * @see
	 *         com.princess.etrak.dao.PropertyDao#getProperty(Long) * @see
	 *         com.princess.etrak.dao.PropertyDao#getProperty(String) * @see
	 *         com.princess.etrak.dao.PropertyDao#getProperty(String)
	 */
	public Property getProperty(int id) {
		if (logger.isDebugEnabled()) {
			logger.debug("getting vendor begins" + id);
		}
		Property vendor = (Property) getCurrentSession()
				.get(Property.class, id);
		if (logger.isDebugEnabled()) {
			logger.debug("getting vendor ends ");
		}
		return vendor;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.princess.etrak.dao.PropertyDao#removeProperty(com.princess.ilo
	 * .model.Property)
	 */
	/**
	 * Method removeProperty.
	 * 
	 * @param vendor
	 *            Property
	 * 
	 * @see com.princess.etrak.dao.PropertyDao#removeProperty(Property)
	 */
	public void removeProperty(Property vendor) {
		if (logger.isDebugEnabled()) {
			logger.debug("removeProperty begins");
		}
		getCurrentSession().delete(vendor);
		if (logger.isDebugEnabled()) {
			logger.debug("removeProperty ends");
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.princess.etrak.dao.PropertyDao#saveProperty(com.princess.etrak.
	 * model.Property)
	 */
	/**
	 * Method saveProperty.
	 * 
	 * @param vendor
	 *            Property
	 * 
	 * @see com.princess.etrak.dao.PropertyDao#saveProperty(Property)
	 */
	public void saveProperty(Property vendor) {
		if (logger.isDebugEnabled()) {
			logger.debug("saveProperty begins: " + vendor);
		}
		getCurrentSession().save(vendor);
		if (logger.isDebugEnabled()) {
			logger.debug("saveProperty ends");
		}
	}

	/**
	 * Method updateProperty.
	 * 
	 * @param vendor
	 *            Property
	 * 
	 * @see com.princess.etrak.dao.PropertyDao#updateProperty(Property)
	 */
	@Override
	public void updateProperty(Property vendor) {
		if (logger.isDebugEnabled()) {
			logger.debug("updateProperty begins: " + vendor);
		}
		getCurrentSession().update(vendor);
		if (logger.isDebugEnabled()) {
			logger.debug("updateProperty ends");
		}
	}

}
